import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.Random;

public class utils
{
	/*正则匹配出文本*/
	public static String getSubstr(String str,String lstr,String rstr){
        Pattern pattern = Pattern.compile(lstr + "(.*?)" + rstr);// 匹配的模式
        Matcher m = pattern.matcher(str);
        while(m.find()){
            return m.group(1);
        }
        return "";
    }
	/*获取当前时间戳*/
	public static String time(boolean isTen)
	{
		if(isTen){
			return Integer.toString((int) (System.currentTimeMillis() / 1000));
		}else{
			return Long.toString(System.currentTimeMillis());
		}
	}
	/*生成指定位数随机数*/
	public static String ranNum(int num){
        StringBuilder str=new StringBuilder();//定义变长字符串
        Random random=new Random();
        for (int i = 0; i < num; i++) {
            str.append(random.nextInt(10));
        }
        return str.toString();
    } 
}
